package com.gobo.eduservice.controller.front;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gobo.commonutils.R;
import com.gobo.eduservice.pojo.EduCourse;
import com.gobo.eduservice.pojo.EduTeacher;
import com.gobo.eduservice.pojo.vo.CourseInfo;
import com.gobo.eduservice.service.EduCourseService;
import com.gobo.eduservice.service.EduTeacherService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/eduservice/front/teacher")
public class FrontTeacherController {

    @Autowired
    private EduTeacherService teacherService;

    @Autowired
    private EduCourseService courseService;

    //获取讲师分页
    @GetMapping("/page/{current}/{size}")
    public R getTeacherPageList(@PathVariable long current, @PathVariable long size){
        Page<EduTeacher> page = new Page<>(current,size);
        Map<String,Object> map = teacherService.getFrontPageList(page);
        return R.ok().data(map);
    }

    //获取讲师详情(包含课程)
    @GetMapping("/info/{id}")
    public R getTeacherInfo(@PathVariable String id){
        EduTeacher eduTeacher = teacherService.getById(id);
        List<EduCourse> eduCourse = courseService.getFrontCourseByTeacherId(id);
        return R.ok().data("teacher",eduTeacher).data("courseList",eduCourse);
    }



}
